﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FulcrumApi.entities
{

    public class StoryErrors
    {

    }

    public class StoryToCreate
    {
        public string Name { get; set; }

        public StoryType Type { get; set; }

        public StoryState State { get; set; }

        public string Description { get; set; }

        public int Estimate { get; set; }
    }

    public enum StoryState
    {

        unscheduled, unstarted, started, finished, delivered, accepted, rejected
    }

    public enum StoryType
    {

        feature, chore, bug, release
    }


    public class Story
    {
    	internal JsonStory story = new JsonStory();

        public Story(JsonStory story)
        {
            this.story = story;
        }

        public StoryType Type { get { return (StoryType) Enum.Parse(typeof (StoryType), story.story_type); } }

        public StoryState State
        {
            get { return (StoryState)Enum.Parse(typeof(StoryState), story.state); }
        }

        public int Estimate
        {
            get { return story.estimate.HasValue ? story.estimate.Value : 0; }
        }

        public String Title
        {
            get { return story.title; }
            set { story.title = value; }
        }

        public int ProjectId
        {
            get { return story.project_id; }
        }

        public String Description
        {
            get { return story.description ?? ""; }
        }

        public int Id
        {
            get { return story.id; }
        }

        public float Position { get { return float.Parse(story.position.Replace('.', ',')); } set { story.position = value.ToString().Replace(',', '.'); } }
    }
    public class JsonStory
    {
        public String accepted_at;
        public String created_at;
        public String description;
        public int? estimate;
        public int id;
        public String labels;
        public int? owned_by_id;
        public String position;
        public int project_id;
        public int? requested_by_id;
        public String state;
        public String story_type;
        public String title;
        public String updated_at;
        public StoryErrors errors;
        public List<String> notes;
    }

    public class FulcrumStory
    {
        public JsonStory story = new JsonStory();
    }
}
